# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        博智科技  
# Name:         exec_demo
# Description:  exec例程
# Author:       yzl
# Date:         2019-01-08
#-------------------------------------------------------------------------------

x = 10
expr = """
z = 30
sum = x + y + z
print(sum)
"""


def func():
    y = 20
    exec(expr)
    exec(expr, {'x': 1, 'y': 2})
    exec(expr, {'x': 1, 'y': 2}, {'y': 3, 'z': 4})
    exec(expr, {'x': 0, 'y': 0}, {'y': 10, 'z': 100})

func()